﻿using System.Data;
using BookTheBook.Data.NameDefinitions;
using Migrator.Framework;

namespace BookTheBook.Migrations
{
    [Migration(1)]
    public class _001_NewTableBook : Migration
    {
        public override void Up()
        {
            Database.AddTable(TableNames.Book, 
                                    new Column(ColumnNames.BookId, DbType.Int32, ColumnProperty.PrimaryKeyWithIdentity),
                                    new Column(ColumnNames.ISBN, DbType.String, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Title, DbType.String, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Author, DbType.String, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Price, DbType.Currency, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Currency, DbType.String, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Publisher, DbType.String, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Edition, DbType.String, ColumnProperty.NotNull),
                                    new Column(ColumnNames.PublishDate, DbType.Date, ColumnProperty.NotNull),
                                    new Column(ColumnNames.Description, DbType.String, ColumnProperty.None));
        }

        public override void Down()
        {
            Database.RemoveTable(TableNames.Book);
        }
    }
}
